<?
/*
Bitsand - a web-based booking system for LRP events
Copyright (C) 2006, 2007 Russell Peter Phillips

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
?>

<?
if ($PLAYER_ID != 0) {
	//Check if player has entered IC & OOC data
	$sql = "SELECT chName FROM characters WHERE chPlayerID = $PLAYER_ID";
	$result = mysqli_query ($link, $sql);
	$iIC = mysqli_num_rows ($result);

	//Check for OOC data needs to check for some actual data, as a record will always exist
	$key = CRYPT_KEY;
	$sql = "SELECT AES_DECRYPT(plFirstName, '$key') AS dFirstName FROM players WHERE plPlayerID = $PLAYER_ID";
	$result = mysqli_query ($link, $sql);
	$row = mysqli_fetch_assoc ($result);
	if ($row ['dFirstName'] != '')
		$bOOC = True;
	else
		$bOOC = False;

	echo "<hr>\n<p>";
	echo "Logged in with Player ID " . PID_PREFIX . sprintf ('%03s', $PLAYER_ID) . "<br>\n";
	echo "<table>\n<tr><td>\n<ul>\n";
	echo "<li><a href = 'start.php'>Start page</a></li>\n";

	//Check if IC & OOC details have been confirmed
	$sql = "SELECT * FROM bookings WHERE bkPlayerID = $PLAYER_ID";
	$result = mysqli_query ($link, $sql);
	$row = mysqli_fetch_assoc ($result);
	$sDateIC = $row ['bkDateICConfirmed'];
	$sOOC = $row ['bkDateOOCConfirmed'];

	if (($sOOC == '' || $sOOC == '0000-00-00') && $bOOC === False)
		echo "<li><a href = 'ooc_form.php'>OOC information</a></li>\n";
	else
		echo "<li><a href = 'ooc_view.php'>OOC information</a></li>\n";
	if (($sDateIC == '' || $sDateIC == '0000-00-00') && $iIC == 0)
		echo "<li><a href = 'ic_form.php'>IC information</a></li>\n";
	else
		echo "<li><a href = 'ic_view.php'>IC information</a></li>\n";
	echo "<li><a href = 'event.php'>Event details</a></li>\n";
	echo "<li><a href = 'bookings.php'>Booking List</a></li>\n";
	echo "</ul>\n</td>\n";
	
	echo "<td>\n<ul>\n";
	echo "<li><a href = 'index.php?green=" . urlencode ("You have been logged out") . "'>Log out</a></li>\n";
	echo "<li><a href = 'change_password.php'>Change password</a></li>\n";
	echo "<li><a href = 'terms.php'>Terms &amp; conditions</a></li>\n";
	echo "<li>Problem? See the <a href = 'faq.php'>FAQ</a> or <a href = 'mailto:" .
		Obfuscate (CONTACT_MAIL) . "'>E-mail " . CONTACT_NAME . "</a></li>\n";
	echo "</ul>\n</td></tr>\n</table>\n";
	echo "</p>\n";
}
?>

<hr>
<p>
The Lions' online booking system is an implementation of Bitsand, a web-based booking system for LRP events. Bitsand is copyright &copy; 2006 Russell Peter Phillips.<br>
Bitsand is free software; you can redistribute it and/or modify it under the terms of the <a href = "http://www.gnu.org/licenses/gpl.html">GNU General Public License</a> as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br>
The lion background image is modified from an <a href = "http://flickr.com/photos/stuartyeates/216280481/">image by Stuart Yeates</a>, released under the Creative Commons <a href = "http://creativecommons.org/licenses/by-sa/2.0/">Attribution-ShareAlike 2.0</a> licence.<br>
<a href = "download.php">Full details, including download links</a>
</p>

<?
//Close link to database
mysqli_close ($link);

if (ini_get ('error_reporting') != 0)
	echo "<p style = 'border: solid thin orange; background: orange; text-align: center;'><b>DEBUG MODE ENABLED</b></p>\n";
?>
</body>
</html>
